﻿using System;
using System.Data;
using System.Configuration;
using System.ServiceModel.Configuration;

namespace PSE.Framework.Service.Security.Authentication.ServiceCredentials
{
    public abstract class CustomServiceCredentialsElement : ServiceCredentialsElement
    {
        public override Type BehaviorType
        {
            get { return typeof(CustomServiceCredentials); }
        }

        protected abstract PSE.Framework.Configuration.SystemComponent GetSystem();
        protected abstract PSE.Framework.Configuration.SystemComponent GetComponent();

        protected override object CreateBehavior()
        {
            PSE.Framework.Configuration.ApplicationConfiguration.Initialize(this.GetSystem(), this.GetComponent());

            CustomServiceCredentials serviceCredential = new CustomServiceCredentials();
            
            base.ApplyConfiguration(serviceCredential);
            
            return serviceCredential;
        }
    }
}
